/*******************************************************************************
 * Copyright (c) 2011 Irineu Martins de Lima Moura (imlm2).
 * This file is part of JBeat.
 * 
 *     JBeat is free software: you can redistribute it and/or modify
 *     it under the terms of the GNU Lesser General Public License as published by
 *     the Free Software Foundation, either version 3 of the License, or
 *     (at your option) any later version.
 * 
 *     JBeat is distributed in the hope that it will be useful,
 *     but WITHOUT ANY WARRANTY; without even the implied warranty of
 *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *     GNU Lesser General Public License for more details.
 * 
 *     You should have received a copy of the GNU Lesser General Public License
 *     along with JBeat.  If not, see <http://www.gnu.org/licenses/>.
 * 
 * Contributors:
 *     Irineu Martins de Lima Moura (imlm2) - initial API and implementation
 ******************************************************************************/
package br.ufpe.cin.imlm2.jbeat.soot.throwableset.generation;

import soot.Body;
import soot.RefType;
import soot.jimple.AssignStmt;
import soot.jimple.BreakpointStmt;
import soot.jimple.EnterMonitorStmt;
import soot.jimple.ExitMonitorStmt;
import soot.jimple.GotoStmt;
import soot.jimple.IdentityStmt;
import soot.jimple.IfStmt;
import soot.jimple.InvokeStmt;
import soot.jimple.LookupSwitchStmt;
import soot.jimple.NopStmt;
import soot.jimple.RetStmt;
import soot.jimple.ReturnStmt;
import soot.jimple.ReturnVoidStmt;
import soot.jimple.TableSwitchStmt;
import soot.jimple.ThrowStmt;
import br.ufpe.cin.imlm2.jbeat.soot.throwableset.InstructionVisitor;

public class RaisesVisitor extends InstructionVisitor {

	public RaisesVisitor(Body b) {
		super(b);
	}

	@Override
	public void caseBreakpointStmt(BreakpointStmt stmt) {
		// Empty.
	}

	@Override
	public void caseInvokeStmt(InvokeStmt stmt) {
		// Empty.
	}

	@Override
	public void caseAssignStmt(AssignStmt stmt) {
		// Empty.
	}

	@Override
	public void caseIdentityStmt(IdentityStmt stmt) {
		// Empty.
	}

	@Override
	public void caseEnterMonitorStmt(EnterMonitorStmt stmt) {
		// Empty.
	}

	@Override
	public void caseExitMonitorStmt(ExitMonitorStmt stmt) {
		// Empty.
	}

	@Override
	public void caseGotoStmt(GotoStmt stmt) {
		// Empty.
	}

	@Override
	public void caseIfStmt(IfStmt stmt) {
		// Empty.
	}

	@Override
	public void caseLookupSwitchStmt(LookupSwitchStmt stmt) {
		// Empty.
	}

	@Override
	public void caseNopStmt(NopStmt stmt) {
		// Empty.
	}

	@Override
	public void caseRetStmt(RetStmt stmt) {
		// Empty.
	}

	@Override
	public void caseReturnStmt(ReturnStmt stmt) {
		// Empty.
	}

	@Override
	public void caseReturnVoidStmt(ReturnVoidStmt stmt) {
		// Empty.
	}

	@Override
	public void caseTableSwitchStmt(TableSwitchStmt stmt) {
		// Empty.
	}

	@Override
	public void caseThrowStmt(ThrowStmt stmt) {
		this.cache.clear();
		RefType t = (RefType)stmt.getOp().getType();
		this.cache.add(t.getSootClass());
		this.filterTrappedOnes(stmt);
		this.exceptions.addAll(this.cache);
	}

	@Override
	public void defaultCase(Object obj) {
		// Empty.
	}

}
